package Leetcode;

/**
 * @ Author     ：侯耀祖
 * @ Description：
 */
public class rotate2 {
    public void rotate(int[][] matrix) {
        int temp = 0;
        for (int i = 0; i < matrix.length; i++) {
            for (int j = i; j < matrix[0].length; j++) {
                temp = matrix[i][j];
                matrix[i][j] = matrix[j][i];
                matrix[j][i] = temp;
            }
        }
        int left = 0;
        int right = matrix.length - 1;
        while (left < right){
            for (int i = 0; i < matrix.length; i++) {
                temp = matrix[i][left];
                matrix[i][left] = matrix[i][right];
                matrix[i][right] = temp;
            }
            left++;
            right--;
        }
    }
}
